//axios 封装
const instance = axios.create({
    baseURL: 'http://47.119.134.71:8080/',
    headers: {
        'Content-Type': 'text/plain;charset=UTF-8'
    }
})




// 渲染物品的组件
var app = new Vue({
    el: "#app",
    data: {
        goods: [],

    },
    methods: {
        get_goods: function() {

            axios.get("http://47.119.134.71:8080/api/goods/getByPage?page=1")
                .then(res => {
                    this.goods = res.data.data
                })
                .catch(err => {
                    console.log(err)
                })

        }
    },
    mounted: function() {
        this.get_goods()
    }

})

// 检查用户是否已经登录的组件
var app2 = new Vue({
    el: "#top",
    data: {
        user_id: -1,
        user_name: ''
    },
    methods: {

    },
    mounted: function() {
        instance({
            method: 'get',
            url: 'api/user/getIdBySession',

        }).then(res => {
            this.user_id = res.data.data.user_id
            this.user_name = res.data.data.user_name

        }).catch(err => {
            console.log(err);
        })
    }
})